import Cookies from 'js-cookie'
import router from '@/router'

const TokenKey = 'electronicBankToken'

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  return Cookies.set(TokenKey, token)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}

export function resetRoute() {
  validRoute(router.options.routes)
}

function validRoute(routes) {
  if (routes != undefined) {
    routes.forEach((element) => {
      if (element != undefined) {
        element.meta.visiable = false;
        validRoute(element.children);
      }
    })
  }
}